<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>示例1</title>
    <script src="jquery.js" type="text/javascript"></script>
    <script>
    function show(){
        const count = $("input[name='hobby']:checked").length
        console.log(count)
    }
    </script>
</head>
<body>
    <div>
        <input type="checkbox" value="sing" name="hobby"/>唱歌
        <input type="checkbox" value="dance" name="hobby"/>跳舞
        <input type="checkbox" value="walk" name="hobby"/>走路
        <button onclick="show()">检查</button>
    </div>
</body>
</html>